package com.ebc.eservice.controller.pc;

import com.ebc.eservice.service.EbcCompanySectorService;
import com.ebc.eservice.util.JsonResult;
import com.ebc.eservice.util.common.constant.ApiTextHelperConstant;
import com.ebc.eservice.util.common.constant.DeveloperConstant;
import com.ebc.eservice.vo.sector.SectorInfoReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Joey
 * @Description: 公司组织 部门
 * @date:2022/10/5 22:34
 */
@Api(tags = "后台管理系统-设置-组织部门")
@RestController
@RequestMapping("/system/sectors")
public class CompanySectorController {

    @Autowired
    private EbcCompanySectorService sectorService;

    @ApiOperation(value = "获取部门列表 一级+二级  @arg: companyId", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/getSectorList")
    public JsonResult getSectorList(@RequestBody SectorInfoReq InfoReq){
        return sectorService.getSectorByCompany(InfoReq.getCompanyId());
    }
    @ApiOperation(value = "添加一级部门 @arg: sectorName companyId", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/addSectorParent")
    public JsonResult addSectorParent(@RequestBody SectorInfoReq InfoReq){
        return sectorService.addSectorParent(InfoReq);
    }
    @ApiOperation(value = "添加二级部门 [sectorId为一级部门id] @arg: sectorId sectorName companyId", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/addSectorChild")
    public JsonResult addSectorChild(@RequestBody SectorInfoReq InfoReq){
        return sectorService.addSectorChild(InfoReq);
    }
    @ApiOperation(value = "删除部门 @arg: sectorId", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/deleteSector")
    public JsonResult deleteSector(@RequestBody SectorInfoReq InfoReq){
        return sectorService.deleteSector(InfoReq);
    }

}
